<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
</html>
<script>
    //数阻的创建 自变量
    let arr= [1,2,3,"4","雷晨军"]
    console.log(arr);
    //构造对象
    let arr2= new Array("a","s")
    console.log(arr2);
    let arr3 =[2]
    arr3[4]= 1
console.log(arr3);

//数阻长度
let arr4= ["雷晨军","下霍顿","赵云"]
arr4[arr4.length] = "刘备"
console.log( arr4);
//数阻判断
let arr5 = [1,2]
console.log(Array.isArray(arr5));
//数组元素添加
let arr6= ["雷晨军","下霍顿","赵云"]
arr6.push("蔡徐坤","陈佳豪")//在数阻末尾添加一个或多个(会改变原数阻)
console.log(arr6);
console.log("............................");
arr6.unshift("牛魔王","曹操","孙策")//在数阻首位添加一个或多个(会改变原数阻)
console.log(arr6);
console.log("..............................");
//合并数阻
let arr7=["牛魔王","曹操","孙策"]
let arr8=["雷晨军","下霍顿","赵云"]
Array.prototype.push.apply(arr7,arr8)
console.log(arr7);
console.log("..............................");
console.log(arr7.concat(arr8));
console.log([...arr7,...arr8]);
//删除数阻
let arr9=["1","2","3","4"]
arr9.pop()//删除末尾项 改变原数阻
console.log(arr9);
arr9.shift()//删除首项 改变原数阻
console.log(arr9);
//数阻的增删改  splice()这个改变数阻
let arr10=["雷晨军","下霍顿","赵云","牛魔王","蔡徐坤","陈佳豪"]
//arr10.splice(1)//第一个开始位置
// console.log(arr10);
// arr10.splice(1,2)//第一个开始位置 第二个代表删除到的位置
// console.log(arr10);
arr10.splice(1,2,"郑江南")//第一个开始位置 第二个代表长度的位置 第三个代表删除后赋值
console.log(arr10);


</script>